/***********************
*DESC:加载设备的配置文件，完成xml数据至json数据的转换，生成配置参数
*Author:wff 
*Date:2015-05-15
*
************************/
/*****dev:DevLogicCfg,app:DevViewCfg*******/
var xotreedev = new XML.ObjTree();
var dumperdev = new JKL.Dumper();
var xotreeapp = new XML.ObjTree();
var dumperapp = new JKL.Dumper();
var GetCurrDevObj;
var GetCurrAppObj;
var GetAreaid = 0;
var GetAppEpid = 0;
var GetDevIid = 0;
var GetScesetid = 0;
var GetTriggerid = 0;
var GetAlarmid = 0;
var GetAlarmAreaid = 0;
var GetAlarmZoneid = 0;
var isCfgNotNull = false;
function InitAllView()
{
	areaidint = parseInt(GetAreaid);
	epidint = parseInt(GetDevIid);
	scesetint = parseInt(GetScesetid);
	triggeridint = parseInt(GetTriggerid);
	Alarmidint = parseInt(GetAlarmid);
	AlarmAreaidint = parseInt(GetAlarmAreaid);
	AlarmZoneidint = parseInt(GetAlarmZoneid);
	curralarmid = GetAlarmid;
	InitFloorSelecthtml(CurrFloorArry,'SelectFloor');
	currfloorid = $( '#SelectFloor' ).val();
	LoadAreaType(GetCurrFloorAreaData(currfloorid));
	InitSenceTable();
	InitAlarmsDiv();
	
}
function ParseFloorArray()
{
}
function ParseAppCfgJSONData()
{
	if(!GetCurrAppObj.conf.hasOwnProperty("home")){
		return true;
	}
	var Newfloor = GetCurrAppObj.conf.home.floor;
	if(typeof(Newfloor) == "object" && Newfloor.constructor == Array){
	
	$.each(Newfloor,function(indexfloor,itemfloor){
		var currfloorid = itemfloor.id;
		var currfloorname = itemfloor.name;
		
		
		CurrFloorArry.push({ "id": currfloorid, "name": currfloorname });
		$.unique(CurrFloorArry);
		CurrfloorMap.put(currfloorid,currfloorname);
	  	
		
		if(itemfloor.hasOwnProperty("area")){
			
			var Newarea = itemfloor.area;
			if(typeof(Newarea) == "object" && Newarea.constructor == Array){
				
				$.each(Newarea,function(indexarea,itemarea){
					var currareaid = itemarea.id;
					var currareaname = itemarea.name;
					var currareatype = itemarea.atype;
					if( parseInt(currareaid) > parseInt(GetAreaid) )
						GetAreaid = parseInt(currareaid);
					CurrAreaArry.push({"floorid": currfloorid, "id": currareaid, "atype": currareatype, "name": currareaname});
		 			$.unique(CurrAreaArry);
					CurrAreaNameMap.put(currareaid,currareaname);
					if(itemarea.hasOwnProperty("elem")){
						var Newelem = itemarea.elem;
						if(typeof(Newelem) == "object" && Newelem.constructor == Array){
							
							$.each(Newelem, function (index, item) {
								if(parseInt(item.id) > parseInt(GetAppEpid))
									GetAppEpid = parseInt(item.id);
								if( item.view.hasOwnProperty( "shape" ) ){
									CurrElemArry.push({"epid": item.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": item.view.etype,"etypename": item.view.name,"shape": item.view.shape,"count": item.view.count,"distrib": item.view.distrib,"dir": item.view.dir});
								}else
									CurrElemArry.push({"epid": item.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": item.view.etype,"etypename": item.view.name});
								if(item.hasOwnProperty("cmd")){
									CurrElemCMDArry.push(item.cmd);							
								}
								else
									return true;
							})
						}
						else{//elem only one
								if(parseInt(Newelem.id) > parseInt(GetAppEpid))
									GetAppEpid = parseInt(Newelem.id);
								if( Newelem.view.hasOwnProperty( "shape" ) )
									CurrElemArry.push({"epid": Newelem.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": Newelem.view.etype,"etypename": Newelem.view.name,"shape": Newelem.view.shape,"count": Newelem.view.count,"distrib": Newelem.view.distrib,"dir": Newelem.view.dir});
								else
									CurrElemArry.push({"epid": Newelem.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": Newelem.view.etype,"etypename": Newelem.view.name});
								if(Newelem.hasOwnProperty("cmd")){
									CurrElemCMDArry.push(Newelem.cmd);							
								}
						}
					}
					else
						return true;
				})
			}
			else{//area only one
			
				var currareaid = Newarea.id;
				var currareaname = Newarea.name;
				var currareatype = Newarea.atype;
				if( parseInt(currareaid) > parseInt(GetAreaid) )
						GetAreaid = parseInt(currareaid);
				CurrAreaArry.push({"floorid": currfloorid, "id": currareaid, "atype": currareatype, "name": currareaname});
		 		$.unique(CurrAreaArry);
				CurrAreaNameMap.put(currareaid,currareaname);
				if(Newarea.hasOwnProperty("elem")){
						var Newelem = Newarea.elem;
						if(typeof(Newelem) == "object" && Newelem.constructor == Array){
							
							$.each(Newelem, function (index, item) {
								if(parseInt(item.id) > parseInt(GetAppEpid))
									GetAppEpid = parseInt(item.id);
								if( item.view.hasOwnProperty( "shape" ) )
									CurrElemArry.push({"epid": item.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": item.view.etype,"etypename": item.view.name,"shape": item.view.shape,"count": item.view.count,"distrib": item.view.distrib,"dir": item.view.dir});
								else	
								CurrElemArry.push({"epid": item.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": item.view.etype,"etypename": item.view.name});
								if(item.hasOwnProperty("cmd")){
									CurrElemCMDArry.push(item.cmd);							
								}
								else
									return true;
							})
						}
						else{//elem only one
								if(parseInt(Newelem.id) > parseInt(GetAppEpid))
									GetAppEpid = parseInt(Newelem.id);
								if( Newelem.view.hasOwnProperty( "shape" ) )
									CurrElemArry.push({"epid": Newelem.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": Newelem.view.etype,"etypename": Newelem.view.name,"shape": Newelem.view.shape,"count": Newelem.view.count,"distrib": Newelem.view.distrib,"dir": Newelem.view.dir});
								else	
									CurrElemArry.push({"epid": Newelem.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": Newelem.view.etype,"etypename": Newelem.view.name});
								if(Newelem.hasOwnProperty("cmd")){
									CurrElemCMDArry.push(Newelem.cmd);							
								}
						}
					}
			}//areaonlyend
		}//has area end
		else
			return true;
			
	})
	
	
}
else{//floor only one

	var currfloorid = Newfloor.id;
	var currfloorname = Newfloor.name;
	
	
	CurrFloorArry.push({ "id": currfloorid, "name": currfloorname });
	$.unique(CurrFloorArry);
	CurrfloorMap.put(currfloorid,currfloorname);
	
	if(Newfloor.hasOwnProperty("area")){
			
			var Newarea = Newfloor.area;
			if(typeof(Newarea) == "object" && Newarea.constructor == Array){
				
				$.each(Newarea,function(indexarea,itemarea){
					var currareaid = itemarea.id;
					var currareaname = itemarea.name;
					var currareatype = itemarea.atype;
					if( parseInt(currareaid) > parseInt(GetAreaid) )
						GetAreaid = parseInt(currareaid);
					CurrAreaArry.push({"floorid": currfloorid, "id": currareaid, "atype": currareatype, "name": currareaname});
		 			$.unique(CurrAreaArry);
					CurrAreaNameMap.put(currareaid,currareaname);
					if(itemarea.hasOwnProperty("elem")){
						var Newelem = itemarea.elem;
						if(typeof(Newelem) == "object" && Newelem.constructor == Array){
							
							$.each(Newelem, function (index, item) {
								if(parseInt(item.id) > parseInt(GetAppEpid))
									GetAppEpid = parseInt(item.id);
								if( item.view.hasOwnProperty( "shape" ) )
									CurrElemArry.push({"epid": item.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": item.view.etype,"etypename": item.view.name,"shape": item.view.shape,"count": item.view.count,"distrib": item.view.distrib,"dir": item.view.dir});
								else	
									CurrElemArry.push({"epid": item.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": item.view.etype,"etypename": item.view.name});
								if(item.hasOwnProperty("cmd")){
									CurrElemCMDArry.push(item.cmd);							
								}
								else
									return true;
							})
						}
						else{//elem only one
								if(parseInt(Newelem.id) > parseInt(GetAppEpid))
									GetAppEpid = parseInt(Newelem.id);
								if( Newelem.view.hasOwnProperty( "shape" ) )
									CurrElemArry.push({"epid": Newelem.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": Newelem.view.etype,"etypename": Newelem.view.name,"shape": Newelem.view.shape,"count": Newelem.view.count,"distrib": Newelem.view.distrib,"dir": Newelem.view.dir});
								else	
									CurrElemArry.push({"epid": Newelem.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": Newelem.view.etype,"etypename": Newelem.view.name});
								if(Newelem.hasOwnProperty("cmd")){
									CurrElemCMDArry.push(Newelem.cmd);							
								}
						}
					}
					else
						return true;
				})
			}
			else{//area only one
			
				var currareaid = Newarea.id;
				var currareaname = Newarea.name;
				var currareatype = Newarea.atype;
				if( parseInt(currareaid) > parseInt(GetAreaid) )
						GetAreaid = parseInt(currareaid);
				CurrAreaArry.push({"floorid": currfloorid, "id": currareaid, "atype": currareatype, "name": currareaname});
		 		$.unique(CurrAreaArry);
				CurrAreaNameMap.put(currareaid,currareaname);
				if(Newarea.hasOwnProperty("elem")){
						var Newelem = Newarea.elem;
						if(typeof(Newelem) == "object" && Newelem.constructor == Array){
							
							$.each(Newelem, function (index, item) {
								if(parseInt(item.id) > parseInt(GetAppEpid))
									GetAppEpid = parseInt(item.id);
								if( item.view.hasOwnProperty( "shape" ) )
									CurrElemArry.push({"epid": item.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": item.view.etype,"etypename": item.view.name,"shape": item.view.shape,"count": item.view.count,"distrib": item.view.distrib,"dir": item.view.dir});
								else	
									CurrElemArry.push({"epid": item.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": item.view.etype,"etypename": item.view.name});
								if(item.hasOwnProperty("cmd")){
									CurrElemCMDArry.push(item.cmd);							
								}
								else
									return true;
							})
						}
						else{//elem only one
								if(parseInt(Newelem.id) > parseInt(GetAppEpid))
									GetAppEpid = parseInt(Newelem.id);
								if( Newelem.view.hasOwnProperty( "shape" ) )
									CurrElemArry.push({"epid": Newelem.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": Newelem.view.etype,"etypename": Newelem.view.name,"shape": Newelem.view.shape,"count": Newelem.view.count,"distrib": Newelem.view.distrib,"dir": Newelem.view.dir});
								else	
									CurrElemArry.push({"epid": Newelem.id,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": Newelem.view.etype,"etypename": Newelem.view.name});
								if(Newelem.hasOwnProperty("cmd")){
									CurrElemCMDArry.push(Newelem.cmd);							
								}
						}
					}
			}//areaonlyend
		}//has area end
}//flooronlyend

	if(GetCurrAppObj.conf.hasOwnProperty("scenes")){
		var NewScenes = GetCurrAppObj.conf.scenes.sceset;
		if(typeof(NewScenes) == "object" && NewScenes.constructor == Array){
			
			$.each(NewScenes,function(index,item){
				if(parseInt(item.id) > parseInt(GetScesetid))
					GetScesetid = parseInt(item.id);
					var currscenFloorname = CurrfloorMap.get(item.floorid);
					var currscenAreaname = CurrAreaNameMap.get(item.aredid);
				 CurrScenesArry.push({"id": item.id,"floorid": item.floorid,"floorname": currscenFloorname,"aredid": item.aredid,"aredname": currscenAreaname,"name": item.name, "scene": item.scene});
			})
			
		}
		else{
			if(parseInt(NewScenes.id) > parseInt(GetScesetid))
					GetScesetid = parseInt(NewScenes.id);
			var currscenFloorname = CurrfloorMap.get(NewScenes.floorid);
			var currscenAreaname = CurrAreaNameMap.get(NewScenes.aredid);
			CurrScenesArry.push({"id": NewScenes.id,"floorid": NewScenes.floorid,"floorname": currscenFloorname,"aredid": NewScenes.aredid,"aredname": currscenAreaname,"name": NewScenes.name, "scene": NewScenes.scene});
		}
		
	}
	
	/*解析生成枫叶报警主机配置数据*/
	if(GetCurrAppObj.conf.hasOwnProperty("alarms")){
		var NewAlarms = GetCurrAppObj.conf.alarms.alarm;
		if(typeof(NewAlarms) == "object" && NewAlarms.constructor == Array){
			
			$.each(NewAlarms,function(index,item){
				CurrAlarmElemMap.put(item.id, item.name);
				if(parseInt(item.id) > parseInt(GetAlarmid))
					GetAlarmid = parseInt(item.id);
				if(item.hasOwnProperty("area")){	
				//if(item.area != undefined && item.area != null){
					var NewAreas = item.area;
					if(typeof(NewAreas) == "object" && NewAreas.constructor == Array){
						$.each(NewAreas,function(NewAreasindex,NewAreasitem){
							if(parseInt(NewAreasitem.id) > parseInt(GetAlarmAreaid))
								GetAlarmAreaid = parseInt(NewAreasitem.id);
							if(NewAreasitem.hasOwnProperty("zone")){
							//if(NewAreasitem.zone != undefined && NewAreasitem.zone != null){
								var NewAreaZones = NewAreasitem.zone;
								if(typeof(NewAreaZones) == "object" && NewAreaZones.constructor == Array){
									$.each(NewAreaZones,function(NewAreaZonesindex,NewAreaZonesitem){
										if(parseInt(NewAreaZonesitem.id) > parseInt(GetAlarmZoneid))
											GetAlarmZoneid = parseInt(NewAreaZonesitem.id);
										
									})
								}else{
									if(parseInt(NewAreaZones.id) > parseInt(GetAlarmZoneid))
											GetAlarmZoneid = parseInt(NewAreaZones.id);
								}
							}
						})
					}else{
						if(parseInt(NewAreas.id) > parseInt(GetAlarmAreaid))
								GetAlarmAreaid = parseInt(NewAreas.id);
						if(NewAreas.hasOwnProperty("zone")){
						//if(NewAreas.zone != undefined && NewAreas.zone != null){
								var NewAreaZones = NewAreas.zone;
								if(typeof(NewAreaZones) == "object" && NewAreaZones.constructor == Array){
									$.each(NewAreaZones,function(NewAreaZonesindex,NewAreaZonesitem){
										if(parseInt(NewAreaZonesitem.id) > parseInt(GetAlarmZoneid))
											GetAlarmZoneid = parseInt(NewAreaZonesitem.id);
										
									})
								}else{
									if(parseInt(NewAreaZones.id) > parseInt(GetAlarmZoneid))
											GetAlarmZoneid = parseInt(NewAreaZones.id);
								}
						}
					}
				CurrAlarmsArry.push({"id": item.id,"epid": item.epid,"name": item.name,"type": item.type,"area": item.area});
				}
				else
				CurrAlarmsArry.push({"id": item.id,"epid": item.epid,"name": item.name,"type": item.type,"area": 0});
			})
			
		}
		else{//alarm not obj
			CurrAlarmElemMap.put(NewAlarms.id, NewAlarms.name);
			if(parseInt(NewAlarms.id) > parseInt(GetAlarmid))
					GetAlarmid = parseInt(NewAlarms.id);
			if(NewAlarms.hasOwnProperty("area")){	
			var NewAreas = NewAlarms.area;
			if(typeof(NewAreas) == "object" && NewAreas.constructor == Array){
				$.each(NewAreas,function(NewAreasindex,NewAreasitem){
					if(parseInt(NewAreasitem.id) > parseInt(GetAlarmAreaid))
						GetAlarmAreaid = parseInt(NewAreasitem.id);
					if(NewAreasitem.hasOwnProperty("zone")){
					//if(NewAreasitem.zone != undefined && NewAreasitem.zone != null){
						var NewAreaZones = NewAreasitem.zone;
						if(typeof(NewAreaZones) == "object" && NewAreaZones.constructor == Array){
							$.each(NewAreaZones,function(NewAreaZonesindex,NewAreaZonesitem){
								if(parseInt(NewAreaZonesitem.id) > parseInt(GetAlarmZoneid))
									GetAlarmZoneid = parseInt(NewAreaZonesitem.id);
								
							})
						}else{
							if(parseInt(NewAreaZones.id) > parseInt(GetAlarmZoneid))
									GetAlarmZoneid = parseInt(NewAreaZones.id);
						}
					}
				})
			}else{
				if(parseInt(NewAreas.id) > parseInt(GetAlarmAreaid))
						GetAlarmAreaid = parseInt(NewAreas.id);
				if(NewAreas.hasOwnProperty("zone")){
				//if(NewAreas.zone != undefined && NewAreas.zone != null){
						var NewAreaZones = NewAreas.zone;
						if(typeof(NewAreaZones) == "object" && NewAreaZones.constructor == Array){
							$.each(NewAreaZones,function(NewAreaZonesindex,NewAreaZonesitem){
								if(parseInt(NewAreaZonesitem.id) > parseInt(GetAlarmZoneid))
									GetAlarmZoneid = parseInt(NewAreaZonesitem.id);
								
							})
						}else{
							if(parseInt(NewAreaZones.id) > parseInt(GetAlarmZoneid))
									GetAlarmZoneid = parseInt(NewAreaZones.id);
						}
				}
			}
			CurrAlarmsArry.push({"id": NewAlarms.id,"epid": NewAlarms.epid,"name": NewAlarms.name,"type": NewAlarms.type,"area": NewAlarms.area});
		}
		else
		CurrAlarmsArry.push({"id": NewAlarms.id,"epid": NewAlarms.epid,"name": NewAlarms.name,"type": NewAlarms.type,"area": 0});
			
			
		}
		
	}
	
	
	return true;
	
}
function ParseDevCfgJSONData()
{
	
	if(GetCurrDevObj.conf.hasOwnProperty("reactor")){
		var NewTrigger = GetCurrDevObj.conf.reactor.trigger;
		if(typeof(NewTrigger) == "object" && NewTrigger.constructor == Array){
			CurrElemTriggerArry = GetCurrDevObj.conf.reactor.trigger;
			$.each(NewTrigger, function (indexi, itemi) {
												
				if(parseInt(itemi.rid) > parseInt(GetTriggerid))
					GetTriggerid = parseInt(itemi.rid);
			})
		}
		else{
			CurrElemTriggerArry.push(NewTrigger);
			if(parseInt(NewTrigger.rid) > parseInt(GetTriggerid))
					GetTriggerid = parseInt(NewTrigger.rid);
		}
		
	}
	
	
	GetDevIid = parseInt(GetAppEpid);
	
	if( !GetCurrDevObj.conf.hasOwnProperty("path")){
		return true;
	}
	var NewPathI = GetCurrDevObj.conf.path.i;
	if(typeof(NewPathI) == "object" && NewPathI.constructor == Array){
	$.each(NewPathI, function (indexi, itemi) {
												
		if(parseInt(itemi.epid) > parseInt(GetAppEpid))
			GetDevIid = parseInt(itemi.epid);
		var curepid = itemi.epid;
		var ctrlid = itemi.ctrlid;
		var ctrltype = itemi.ctrltype;
		var ctypename = ctrlTypeMap.get(ctrltype);
		if( ctrltype != 3){
			var devtype = itemi.devtype;
			var dtypename = GetDtypeNameByCurrCtype(ctrltype, devtype);
		}
		var dchan = itemi.dchan;
		
		var model = itemi.model;
		//var modelname = ModelTypeMap.get(model);
		var conf = model.substring(2, 4);
		var modelcode = model.substring(6, 8);
		var protocol = model.substring(8, 10);
		var addr1 = itemi.addr1;
		var addr2 = itemi.addr2;
		if(addr1 == "" || addr1 == undefined || addr1 == "undefined")
			addr1 = "";
		if(addr2 == "" || addr2 == undefined || addr2 == "undefined")
			addr2 = "";
		
		$.each(CurrElemArry, function (index, item) {
			if( item.epid == curepid){
				var currfloorid = item.floorid;
				var currfloorname = item.floorname;
				var currareaid = item.atype;
				var currareaname = item.atypename;
				var curretype = item.etype;
				var curretypename = item.etypename;
				var isHasshap = false;
				if( item.hasOwnProperty( "shape" ) ){
					isHasshap = true;
					var curreshape = item.shape;
					var currecount = item.count;
					var curredistrib = item.distrib;
					var curredir = item.dir;
					
				}
				CurrElemArry.splice(index, 1);
				if( ctrltype != 3){
					if(isHasshap)
						CurrElemArry.push({"epid": curepid,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": curretype,"etypename": curretypename,"ctrlid": ctrlid,"ctrltype": ctrltype,"ctypename": ctypename,"devtype": devtype,"dtypename": dtypename,"dchan": dchan,"conf": conf,"modelcode": modelcode,"protocol": protocol,"model": model,"addr1": addr1,"addr2": addr2,"shape": curreshape,"count": currecount,"distrib": curredistrib,"dir": curredir});
					else
						CurrElemArry.push({"epid": curepid,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": curretype,"etypename": curretypename,"ctrlid": ctrlid,"ctrltype": ctrltype,"ctypename": ctypename,"devtype": devtype,"dtypename": dtypename,"dchan": dchan,"conf": conf,"modelcode": modelcode,"protocol": protocol,"model": model,"addr1": addr1,"addr2": addr2});
				}
				else{
					if(isHasshap)
						CurrElemArry.push({"epid": curepid,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": curretype,"etypename": curretypename,"ctrlid": ctrlid,"ctrltype": ctrltype,"ctypename": ctypename,"dchan": dchan,"conf": conf,"modelcode": modelcode,"protocol": protocol,"model": model,"addr1": addr1,"addr2": addr2,"shape": curreshape,"count": currecount,"distrib": curredistrib,"dir": curredir});
					else					
						CurrElemArry.push({"epid": curepid,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": curretype,"etypename": curretypename,"ctrlid": ctrlid,"ctrltype": ctrltype,"ctypename": ctypename,"dchan": dchan,"conf": conf,"modelcode": modelcode,"protocol": protocol,"model": model,"addr1": addr1,"addr2": addr2});
				}
				return false;
									
			}
		})
						
	})
	}
	else{//path i only one
		if(parseInt(NewPathI.epid) > parseInt(GetAppEpid))
			GetDevIid = parseInt(NewPathI.epid);
		var curepid = NewPathI.epid;
		var ctrlid = NewPathI.ctrlid;
		var ctrltype = NewPathI.ctrltype;
		var ctypename = ctrlTypeMap.get(ctrltype);
		if( ctrltype != 3){
			var devtype = NewPathI.devtype;
			var dtypename = GetDtypeNameByCurrCtype(ctrltype, devtype);
		}
		var dchan = NewPathI.dchan;
		//var conf = NewPathI.conf;
		//var modelcode = NewPathI.modelcode;
		//var protocol = NewPathI.protocol;
		var model = NewPathI.model;
		var conf = model.substring(2, 4);
		var modelcode = model.substring(6, 8);
		var protocol = model.substring(8, 10);
		//var modelname = ModelTypeMap.get(model);
		var addr1 = NewPathI.addr1;
		var addr2 = NewPathI.addr2;
		if(addr1 == "" || addr1 == undefined || addr1 == "undefined")
			addr1 = "";
		if(addr2 == "" || addr2 == undefined || addr2 == "undefined")
			addr2 = "";
		$.each(CurrElemArry, function (index, item) {
			if( item.epid == curepid){
				var currfloorid = item.floorid;
				var currfloorname = item.floorname;
				var currareaid = item.atype;
				var currareaname = item.atypename;
				var curretype = item.etype;
				var curretypename = item.etypename;
				var isHasshap = false;
				if( item.hasOwnProperty( "shape" ) ){
					isHasshap = true;
					var curreshape = item.shape;
					var currecount = item.count;
					var curredistrib = item.distrib;
					var curredir = item.dir;
				}
				CurrElemArry.splice(index, 1);
				if( ctrltype != 3){
					if(isHasshap)
						CurrElemArry.push({"epid": curepid,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": curretype,"etypename": curretypename,"ctrlid": ctrlid,"ctrltype": ctrltype,"ctypename": ctypename,"devtype": devtype,"dtypename": dtypename,"dchan": dchan,"conf": conf,"modelcode": modelcode,"protocol": protocol,"model": model,"addr1": addr1,"addr2": addr2,"shape": curreshape,"count": currecount,"distrib": curredistrib,"dir": curredir});
					else
						CurrElemArry.push({"epid": curepid,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": curretype,"etypename": curretypename,"ctrlid": ctrlid,"ctrltype": ctrltype,"ctypename": ctypename,"devtype": devtype,"dtypename": dtypename,"dchan": dchan,"conf": conf,"modelcode": modelcode,"protocol": protocol,"model": model,"addr1": addr1,"addr2": addr2});
				}
				else{
					if(isHasshap)
						CurrElemArry.push({"epid": curepid,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": curretype,"etypename": curretypename,"ctrlid": ctrlid,"ctrltype": ctrltype,"ctypename": ctypename,"dchan": dchan,"conf": conf,"modelcode": modelcode,"protocol": protocol,"model": model,"addr1": addr1,"addr2": addr2,"shape": curreshape,"count": currecount,"distrib": curredistrib,"dir": curredir});
					else					
						CurrElemArry.push({"epid": curepid,"floorid": currfloorid,"floorname": currfloorname,"atype": currareaid,"atypename": currareaname,"etype": curretype,"etypename": curretypename,"ctrlid": ctrlid,"ctrltype": ctrltype,"ctypename": ctypename,"dchan": dchan,"conf": conf,"modelcode": modelcode,"protocol": protocol,"model": model,"addr1": addr1,"addr2": addr2});
				}
				return false;
									
			}
		})
	}

	return true;
	
}
/*获取AppCfgxml 转换成json*/
function GetAppCfgxmlTjson(){
$.ajax({                 
				 
				url : '../orgMgr/devCfg/loadDevViewCfg',				
                type: 'get',  
                dataType: 'text',  
                timeout: 100000,  
                cache: false,
				data:{devNid: currusername},                
				error : function() {
					alert("获取参数超时");
					
					return false;
				},    
                success:  function(dataxml) {
					if(dataxml == ""){
						isCfgNotNull = false;
						InitSenceTable();
					}
					else{
						isCfgNotNull = true;
						var tree = xotreeapp.parseXML(dataxml);					
						GetCurrAppObj = $.parseJSON(dumperapp.dump(tree));
						
						if(ParseAppCfgJSONData() == true){
							GetDevCfgxmlTjson();
						}
					}
					 
				}
				   
})
}
/*获取DevCfgxml 转换成json*/
function GetDevCfgxmlTjson(){
$.ajax({                 
				 
				url : '../orgMgr/devCfg/loadDevLogicCfg',				
                type: 'get',  
                dataType: 'text',  
                timeout: 100000,  
                cache: false,
				data:{devNid: currusername},               
				error : function() {
					alert("获取参数超时");
					return false;
				},    
                success:  function(dataxml) {				
					if(dataxml == ""){
						isCfgNotNull = false;
					}
					else{
						var tree = xotreedev.parseXML(dataxml);					
						GetCurrDevObj = $.parseJSON(dumperdev.dump(tree));
						if(ParseDevCfgJSONData() == true){
							InitAllView();
						}
					}
					 
				}
				   
})
}